package sm.dbdict.def;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class DBDict implements Cloneable, Serializable {

	private static final long serialVersionUID = 3450742233234364746L;

	private String name;

	private List<Field> field;

	private List<Key> key;

	private Integer index_file;

	private Integer index_rec_len;

	private List<Integer> index_pools;

	private Integer data_file;

	private Integer data_rec_len;

	private List<Integer> data_pools;

	private Integer root_record;

	private List<SqlTables> sql_tables;

	private FileOptions file_options;

	private Boolean case_insensitive;

	private Date sysmodtime;

	private String sysmoduser;

	private Integer sysmodcount;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Field> getField() {
		return field;
	}

	public void setField(List<Field> field) {
		this.field = field;
	}

	public List<Key> getKey() {
		return key;
	}

	public void setKey(List<Key> key) {
		this.key = key;
	}

	public Integer getIndex_file() {
		return index_file;
	}

	public void setIndex_file(Integer index_file) {
		this.index_file = index_file;
	}

	public Integer getIndex_rec_len() {
		return index_rec_len;
	}

	public void setIndex_rec_len(Integer index_rec_len) {
		this.index_rec_len = index_rec_len;
	}

	public List<Integer> getIndex_pools() {
		return index_pools;
	}

	public void setIndex_pools(List<Integer> index_pools) {
		this.index_pools = index_pools;
	}

	public Integer getData_file() {
		return data_file;
	}

	public void setData_file(Integer data_file) {
		this.data_file = data_file;
	}

	public Integer getData_rec_len() {
		return data_rec_len;
	}

	public void setData_rec_len(Integer data_rec_len) {
		this.data_rec_len = data_rec_len;
	}

	public List<Integer> getData_pools() {
		return data_pools;
	}

	public void setData_pools(List<Integer> data_pools) {
		this.data_pools = data_pools;
	}

	public Integer getRoot_record() {
		return root_record;
	}

	public void setRoot_record(Integer root_record) {
		this.root_record = root_record;
	}

	public List<SqlTables> getSql_tables() {
		return sql_tables;
	}

	public void setSql_tables(List<SqlTables> sql_tables) {
		this.sql_tables = sql_tables;
	}

	public FileOptions getFile_options() {
		return file_options;
	}

	public void setFile_options(FileOptions file_options) {
		this.file_options = file_options;
	}

	public Boolean getCase_insensitive() {
		return case_insensitive;
	}

	public void setCase_insensitive(Boolean case_insensitive) {
		this.case_insensitive = case_insensitive;
	}

	public Date getSysmodtime() {
		return sysmodtime;
	}

	public void setSysmodtime(Date sysmodtime) {
		this.sysmodtime = sysmodtime;
	}

	public String getSysmoduser() {
		return sysmoduser;
	}

	public void setSysmoduser(String sysmoduser) {
		this.sysmoduser = sysmoduser;
	}

	public Integer getSysmodcount() {
		return sysmodcount;
	}

	public void setSysmodcount(Integer sysmodcount) {
		this.sysmodcount = sysmodcount;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((case_insensitive == null) ? 0 : case_insensitive.hashCode());
		result = prime * result
				+ ((data_file == null) ? 0 : data_file.hashCode());
		result = prime * result
				+ ((data_pools == null) ? 0 : data_pools.hashCode());
		result = prime * result
				+ ((data_rec_len == null) ? 0 : data_rec_len.hashCode());
		result = prime * result + ((field == null) ? 0 : field.hashCode());
		result = prime * result
				+ ((file_options == null) ? 0 : file_options.hashCode());
		result = prime * result
				+ ((index_file == null) ? 0 : index_file.hashCode());
		result = prime * result
				+ ((index_pools == null) ? 0 : index_pools.hashCode());
		result = prime * result
				+ ((index_rec_len == null) ? 0 : index_rec_len.hashCode());
		result = prime * result + ((key == null) ? 0 : key.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((root_record == null) ? 0 : root_record.hashCode());
		result = prime * result
				+ ((sql_tables == null) ? 0 : sql_tables.hashCode());
		result = prime * result
				+ ((sysmodcount == null) ? 0 : sysmodcount.hashCode());
		result = prime * result
				+ ((sysmodtime == null) ? 0 : sysmodtime.hashCode());
		result = prime * result
				+ ((sysmoduser == null) ? 0 : sysmoduser.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DBDict other = (DBDict) obj;
		if (case_insensitive == null) {
			if (other.case_insensitive != null)
				return false;
		} else if (!case_insensitive.equals(other.case_insensitive))
			return false;
		if (data_file == null) {
			if (other.data_file != null)
				return false;
		} else if (!data_file.equals(other.data_file))
			return false;
		if (data_pools == null) {
			if (other.data_pools != null)
				return false;
		} else if (!data_pools.equals(other.data_pools))
			return false;
		if (data_rec_len == null) {
			if (other.data_rec_len != null)
				return false;
		} else if (!data_rec_len.equals(other.data_rec_len))
			return false;
		if (field == null) {
			if (other.field != null)
				return false;
		} else if (!field.equals(other.field))
			return false;
		if (file_options == null) {
			if (other.file_options != null)
				return false;
		} else if (!file_options.equals(other.file_options))
			return false;
		if (index_file == null) {
			if (other.index_file != null)
				return false;
		} else if (!index_file.equals(other.index_file))
			return false;
		if (index_pools == null) {
			if (other.index_pools != null)
				return false;
		} else if (!index_pools.equals(other.index_pools))
			return false;
		if (index_rec_len == null) {
			if (other.index_rec_len != null)
				return false;
		} else if (!index_rec_len.equals(other.index_rec_len))
			return false;
		if (key == null) {
			if (other.key != null)
				return false;
		} else if (!key.equals(other.key))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (root_record == null) {
			if (other.root_record != null)
				return false;
		} else if (!root_record.equals(other.root_record))
			return false;
		if (sql_tables == null) {
			if (other.sql_tables != null)
				return false;
		} else if (!sql_tables.equals(other.sql_tables))
			return false;
		if (sysmodcount == null) {
			if (other.sysmodcount != null)
				return false;
		} else if (!sysmodcount.equals(other.sysmodcount))
			return false;
		if (sysmodtime == null) {
			if (other.sysmodtime != null)
				return false;
		} else if (!sysmodtime.equals(other.sysmodtime))
			return false;
		if (sysmoduser == null) {
			if (other.sysmoduser != null)
				return false;
		} else if (!sysmoduser.equals(other.sysmoduser))
			return false;
		return true;
	}

	@Override
	public Object clone() {
		try {
			DBDict clonedObj = (DBDict) super.clone();
			clonedObj.case_insensitive = case_insensitive;
			clonedObj.data_file = data_file;
			if (data_pools != null) {
				clonedObj.data_pools = new ArrayList<Integer>();
				for (Integer pool : data_pools) {
					clonedObj.data_pools.add(pool);
				}
			}

			clonedObj.data_rec_len = data_rec_len;
			if (field != null) {
				clonedObj.field = new ArrayList<Field>();
				for (Field f : field) {
					clonedObj.field.add((Field) f.clone());
				}
			}
			clonedObj.file_options = (FileOptions) file_options.clone();
			clonedObj.index_file = index_file;
			if (index_pools != null) {
				clonedObj.index_pools = new ArrayList<Integer>();
				for (Integer pool : index_pools) {
					clonedObj.index_pools.add(pool);
				}
			}
			clonedObj.index_rec_len = index_rec_len;
			if (key != null) {
				clonedObj.key = new ArrayList<Key>();
				for (Key k : key) {
					clonedObj.key.add((Key) k.clone());
				}
			}
			clonedObj.name = name;
			clonedObj.root_record = root_record;
			if (sql_tables != null) {
				clonedObj.sql_tables = new ArrayList<SqlTables>();
				for (SqlTables t : sql_tables) {
					clonedObj.sql_tables.add((SqlTables) t.clone());
				}
			}
			clonedObj.sysmodcount = sysmodcount;
			clonedObj.sysmodtime = (Date) sysmodtime.clone();
			clonedObj.sysmoduser = sysmoduser;
			return clonedObj;
		} catch (CloneNotSupportedException e) {
			// this shouldn't happen, since we are Cloneable
			throw new InternalError();
		}
	}
}
